package com.open.capacity.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.open.capacity.mapper.ActivityDao2;
import com.open.capacity.model.ActivityModel;
import com.open.capacity.model.PageModel;
import com.open.capacity.service.ActivityService2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ActivityServiceImpl2 implements ActivityService2 {
    @Autowired
    private ActivityDao2 activityDao2;

    @Override
    public void update(ActivityModel activityModel) {
        activityDao2.update(activityModel);
    }

    @Override
    public void del(Long actiid) {
        activityDao2.del(actiid);
    }

    @Override
    public void add(ActivityModel activityModel) {
        activityDao2.add(activityModel);
    }

    @Override
    public PageInfo<ActivityModel> findByPage(PageModel pageModel,ActivityModel activityModel) {
        PageHelper.startPage(pageModel.getPage(),pageModel.getLimit());
        List<ActivityModel> list= activityDao2.findByPage(activityModel);
        PageInfo<ActivityModel> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<ActivityModel> findAll() {
        return activityDao2.findAll();
    }

    @Override
    public void upstate(int i, Date date) {
        activityDao2.upstate(i,date);
    }

    @Override
    public ActivityModel findById(Long actiid) {
        return activityDao2.findById(actiid);
    }
}
